#include "strategy.h"


int pick_coins(int round_id,
               int initial_coins,
               int opponent_last_pick,
               void *state_memory,
               size_t state_size)
{
    int current_coins;
    if(round_id % 2 == 1)
    {
	current_coins = initial_coins - (round_id - 1) / 2;
    }
    else
    {
	current_coins = initial_coins - (round_id - 2) / 2;
    }

    // 目标是让对手面对4的倍数加1的情况（必败态）
    int remainder = current_coins % 4;
    if (remainder == 0 || remainder == 1)
    {
	// 如果当前处于必败态，尽量让对手也处于必败态
	return 1;
    }
    else
    {
	// 让对手处于必败态
	return remainder - 1;
    }    
}
